<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        // 1.创建xhr对象
        let xhr = new XMLHttpRequest()
        // 2.调用open函数指定请求方式和URL地址
        xhr.open('GET', '{name:zs,age:12}')
        // 3.调用send函数发起ajax请求
        xhr.send()
        // 4.监听onreadystatechange事件
        xhr.onreadystatechange = () => {
            // 如果服务器能够连接则返回数据
            if (xhr.readyState === 4 && xhr.status === 200) console.log(xhr.responseText);
        }
    </script>
</body>

</html>